﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UvsChess;
namespace StudentAI
{
    class Node
    {
        public Node parent;
        public ChessBoard currBoard;
        public ChessMove move;
        public ChessColor color;
        public int depth;
        public int? score;
        public Node(Node _parent, ChessBoard _currBoard, ChessMove _move, ChessColor _color, int _depth, int? _score = null)
        {
            parent = _parent;
            currBoard = _currBoard;
            move = _move;
            color = _color;
            depth = _depth;
            score = _score;
        }
        public bool betterThanParentScore(int? newScore)
        {

            //black = negative
            //white = positive
            ChessColor currNodesColor = color;
            ChessColor parentNodesColor = parent.color;
            int tDepth = depth % 2;
//            if (tDepth == 0)
//                newScore *= -1;
            if(parent.score == null)
                return true;
            //when tDepth is zero, parent wants lower score
            //when tDepth is one, parent wants higher score        
            if (tDepth == 0 && newScore < parent.score)
                return true;
            if (tDepth == 1 && newScore > parent.score)
                return true;
            
            return false;
        }
    }
}
